All files / src App.vue

82.35% Statements 14/17
100% Branches 4/4
75% Functions 3/4
82.35% Lines 14/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99                                        1x 1x 1x                         11x                                 10x   6x 1x           6x 2x         6x                   6x       4x 4x 4x                              
<template>
    <div id="filemanager-app" class="row">
        <x-test id="action::surveyResources"></x-test>
        <div class="container-fluid">
            <nav-bar :loading="loading" @setLoading="setLoading" @forceRedraw="triggerForceRedraw"/>
            <div class="row" v-if="!hasError">
                <folder-list :loading="loading" @setLoading="setLoading" :cols="4" :preset-folder="presetFolder" />
                <file-list :loading="loading" @setLoading="setLoading" :cols="8" />
            </div>
            <div class="row" v-if="hasError">
                <div class="ls-flex ls-flex-column align-content-center align-items-center">
                    <div class="alert alert-warning">{{"An error has happened and no files could be located"|translate}}</div>
                </div>
            </div>
        </div>
        <iframe id="fileManager-DownloadFrame" src="about:blank" frameborder="0" height="0" width="0" />
    </div>
</template>
 
<script>
import NavBar from "./components/NavBar.vue";
import FolderList from "./components/FolderList.vue";
import FileList from "./components/FileList.vue";
 
export default {
    name: "filemanager",
    components: {
        NavBar,
        FolderList,
        FileList
    },
    props: {
        presetFolder: {type: String|null, default: null}
    },
    data() {
        return {
            loading: true,
            hasError: false
        };
    },
    methods: {
        setLoading(nV) {
            this.$log.log("Loading set on base component");
            this.loading = nV;
        },
        triggerForceRedraw() {
            // this.loading=true;
            this.$forceUpdate();
            // window.setTimeout(()=>{this.loading=false}, 250);
        }
    },
    mounted() {
        this.$store.dispatch("getFolderList").then(result => {
            
            if(this.presetFolder != null) {
                this.$store.commit(
                    "setCurrentFolder",
                    this.presetFolder
                );
            }
 
            if (this.$store.state.currentFolder == null) {
                this.$store.commit(
                    "setCurrentFolder",
                    this.$store.state.folderList[0].folder
                );
            }
            this.$store.dispatch("getFileList")
            .catch(error => {
                window.LS.notifyFader(
                    `${this.translate("An error has occured and the file list could not be loaded:")}
Error: 
${error.data.message}`,
                    'well-lg bg-danger text-center'
                );
            })
            .finally(() => {
                this.loading = false;
            });
        })
        .catch((error) => {
            this.$log.error(error);
            this.loading = false;
            this.hasError = true;
            window.LS.notifyFader(
                `${this.translate("An error has occured and the folders could not be loaded:")}
Error: 
${error.data.message}`,
                'well-lg bg-danger text-center'
            );
        });
    }
};
</script>
 
<style>
 
</style>